package org.example.node;

import java.util.ArrayList;
import java.util.List;

/**
 * @author liyishan
 * @date 2024/6/13 10:37
 * @apiNote
 */

public class Test00589Preorder {

    public List<Integer> preorder(Node root) {
        List<Integer> res = new ArrayList<>();
        helper(root,res);
        return res;
    }

    public void helper(Node root,List<Integer> res){
        if(root == null){
            return;
        }
        res.add(root.val);
        for(Node child : root.children){
            helper(child,res);
        }
    }
}
